#ifndef __LCD_H
#define __LCD_H
#include "main.h"
#include "bsp_spi.h"
/* Description 
LTS225KP-PF09 is a 76RGBX284 dot-matrix TFT LCD module. This module is composed of a TFT LCD 
Panel, driver ICs, FPC and a Backlight unit.
ST7789P3
*/ 
 

#define usr_lcd_spi hspi2

#define USE_HORIZONTAL 0
#if USE_HORIZONTAL == 0 || USE_HORIZONTAL == 1
#define LCD_W 76
#define LCD_H 284
#else
#define LCD_W 284
#define LCD_H 76
#endif


// 命令还是数据
typedef enum
{
   LCD_CMD,
   LCD_DATA,
} LCD_DCType;



// RESET PA 8
#define LCD_RES_Clr() GPIOA->ODR &= ~(0x01 << 8);
#define LCD_RES_Set() GPIOA->ODR |= (0x01 << 8);
// PB 14
#define LCD_DC_Clr() GPIOB->ODR &= ~(0x01 << 14);
#define LCD_DC_Set() GPIOB->ODR |= (0x01 << 14);
// PB12
#define LCD_CS_Clr() GPIOB->ODR &= ~(0x01 << 12);
#define LCD_CS_Set() GPIOB->ODR |= (0x01 << 12);

 // PA 9  背光
 #define LCD_BLK_Set() GPIOA->ODR &= ~(0x01 << 9);
 #define LCD_BLK_Clr() GPIOA->ODR |= (0x01 << 9);

void LCD_GPIO_Init(void);
void LCD_Init(void);


void LCD_Fill(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye, uint16_t color);
void LCD_ShowPicture(u16 x,u16 y,u16 length,u16 width,const u8 pic[]);
void LCD_ShowPicture_DMA(u16 x, u16 y, u16 length, u16 width, const u8 pic[]);

#endif
